#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<unistd.h>
#include<fcntl.h>


#define SIZE 128

int main()
{

  close(1);
  //O_TRUNC
  int fd = open("log.txt",O_APPEND | O_WRONLY | O_CREAT  , 0644);
  if(fd<0){
    perror("open error\n");
    return 1;
  }
  const char *str ="hello world\n";
  write(1,str,strlen(str));
  close(fd);

  return 0;
}
